// @before-stub-for-debug-begin
#include <vector>
#include <string>
#include "commoncppproblem155.h"

using namespace std;
// @before-stub-for-debug-end

/*
 * @FilePath: \undefinedc:\Users\sxjct\.leetcode\155.最小栈.cpp
 * @Brief: 
 * @Version: 1.0
 * @Date: 2021-04-12 15:27:23
 * @Author: tianyiyi
 * @Copyright: Copyright@tianyiyi
 * @LastEditors: Mr.Tian
 * @LastEditTime: 2021-04-12 15:59:44
 */
/*
 * @lc app=leetcode.cn id=155 lang=cpp
 *
 * [155] 最小栈
 */

// @lc code=start
class MinStack {
    stack<int> stk;     // 用于存储最小元素的栈
    stack<int> minStk;  // 正常的栈
public:
    /** initialize your data structure here. */
    MinStack() {
        minStk.push(INT_MAX);
    }
    
    void push(int val) {
        stk.push(val);
        minStk.push(min(val,minStk.top()));
    }
    
    void pop() {
        minStk.pop();
        stk.pop();
        
    }
    
    int top() {
        return stk.top();
    }
    
    int getMin() {
        return minStk.top();
    }
};

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack* obj = new MinStack();
 * obj->push(val);
 * obj->pop();
 * int param_3 = obj->top();
 * int param_4 = obj->getMin();
 */
// @lc code=end

